package com.teamcenter.rac.massupdate.utils;

import com.teamcenter.rac.common.Activator;
import com.teamcenter.rac.common.propertyicon.IPropertyIconService;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.util.OSGIUtil;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;

public class ImageRegistryManager {
	private static ImageRegistryManager m_registryManager;
	private IPropertyIconService m_renderIconObjectService = (IPropertyIconService) OSGIUtil
			.getService(Activator.getDefault(), IPropertyIconService.class);
	private ImageRegistry m_imageRegistry = new ImageRegistry(Display.getDefault());

	public Image getImageFromRegistry(TCComponent paramTCComponent, String paramString) {
		String str = this.m_renderIconObjectService.generateComponentKey(paramTCComponent, paramString);
		return this.m_imageRegistry.get(str);
	}

	public void putImageInRegistry(TCComponent paramTCComponent, String paramString, Image paramImage) {
		if (paramImage == null) {
			return;
		}
		String str = this.m_renderIconObjectService.generateComponentKey(paramTCComponent, paramString);
		if (this.m_imageRegistry.get(str) == null) {
			this.m_imageRegistry.put(str, paramImage);
		}
	}

	public void putImageInRegistry(String paramString, Image paramImage) {
		if ((paramImage == null) || (paramString == null) || (paramString.isEmpty())) {
			return;
		}
		if (this.m_imageRegistry.get(paramString) == null) {
			this.m_imageRegistry.put(paramString, paramImage);
		}
	}

	public Image getImageFromRegistry(String paramString) {
		return this.m_imageRegistry.get(paramString);
	}

	public static ImageRegistryManager getInstance() {
		if (m_registryManager == null) {
			m_registryManager = new ImageRegistryManager();
		}
		return m_registryManager;
	}
}
